
public class Test {

    int n;

    public void printInfo() {

        try {

            System.out.println("求12的因子个数");

            n = f(12);

            System.out.println("12的因子个数为" + n);

        } catch (Exception e) {

            System.out.println("求12的因子个数有误");

        } finally {

            System.out.println("结束");

        }

    }

    public int f(int n) {

        int y = 0;

        for (int i = n; i >= 0; i--) {

            if (n % i == 0) y++;

        }

        return y;

    }

    public static void main(String args[]) {

        Test tf = new Test();

        tf.printInfo();

    }

}